using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CodeStory.Core;
using CodeStory.Core.UI;
using CodeStory.Core.Providers;

namespace CodeStory.WebApplication.Modules.Core.Admin
{
	public partial class SiteSetting : Portlet
	{

		protected override void OnInit(EventArgs e) {
			Load += new EventHandler(SiteSetting_Load);
			btnSave.Click += new EventHandler(ButtonSave_Click);
			base.OnInit(e);
		}

		void ButtonSave_Click(object sender, EventArgs e) {
			CodeStorySiteSetting obj = PropertyGrid1.SelectedObject as CodeStorySiteSetting;
			if (obj != null) {
				obj.Save();
				CodeStorySiteSetting.Current.Refresh();
			}
		}

		void SiteSetting_Load(object sender, EventArgs e) {
			if (!IsPostBack) {
				BindObject();
			}
		}

		private void BindObject() {
			CodeStorySiteSetting setting = CodeStorySiteSetting.Current;
			PropertyGrid1.SelectedObject = setting;
			PropertyGrid1.DataBind();
		}
	}
}